import math


class Target:

    __name__ = None

    __x__ = None

    __y__ = None

    __w__ = None

    __h__ = None

    __number__ = None

    def __init__(self, name, x, y, w, h):
        self.__name__ = name
        self.__x__ = x
        self.__y__ = y
        self.__w__ = w
        self.__h__ = h

    def get_name(self):
        return self.__name__

    def get_x(self):
        return self.__x__

    def get_y(self):
        return self.__y__

    def get_w(self):
        return self.__w__

    def get_h(self):
        return self.__h__

    def get_center(self):
        return self.__x__ + self.__w__ / 2, self.__y__ + self.__h__ / 2

    def get_left_center(self):
        return self.__x__, self.__y__ + self.__h__ / 2

    def get_right_center(self):
        return self.__x__ + self.__w__, self.__y__ + self.__h__ / 2

    def get_distance(self, target):
        return math.sqrt(
            (self.get_center()[0] - target.get_center()[0]) ** 2 +
            (self.get_center()[1] - target.get_center()[1]) ** 2
        )

    def have_right(self, target_list):
        one_target_x = self.get_right_center()[0]

        for i in range(len(target_list)):
            two_target_x = target_list[i].get_left_center()[0]
            if one_target_x <= two_target_x and self.get_distance(target_list[i]) < 100:
                return True, i
        return False, None

    def set_number(self, number):
        self.__number__ = number

    def get_number(self):
        return self.__number__
